package com.yusys.jin.blog.controller;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class TestCase {
    public static void main(String[] args) throws DocumentException {
        Map<Integer, Map> firstMenu = null;
        SAXReader reader = new SAXReader();
        String path = System.getProperty("user.dir") + "\\src\\main\\resources\\static\\config\\menu.xml";
//		D:\Users\LENOVO\git\IndexForFreeDream\src\main\resources\static\config
        Document doc = reader.read(new File(path));
        Element root = doc.getRootElement();
        List<Element> list = root.elements();
        for (Element e : list) {
            firstMenu = new HashMap<Integer, Map>();
            Integer key = Integer.parseInt(e.attributeValue("state"));
            List<Element> value = e.elements();
            Map<Integer, String> secondMenu = new HashMap<Integer, String>();
            for (Element a : value) {
                Integer secondKey = Integer.parseInt(a.attributeValue("state"));
                String secondValue = a.getText();
                secondMenu.put(secondKey, secondValue);
            }
            firstMenu.put(key, secondMenu);
        }

        System.err.println(firstMenu);
        System.err.println(path);
    }
}
